import 'package:drift/drift.dart';
// 注释掉旧的导入
// import 'package:drift/web.dart';
// 导入新的 wasm 支持
import 'package:drift/wasm.dart';
import 'dart:async' show Future;

/// 创建Web数据库连接
Future<DatabaseConnection> createWebDatabase() async {
  final result = await WasmDatabase.open(
    databaseName: 'flowplan',
    sqlite3Uri: Uri.parse('sqlite3.wasm'),
    driftWorkerUri: Uri.parse('drift_worker.dart.js'),
  );
  return result.resolvedExecutor;
}

/// 创建数据库连接（用于条件导入）
Future<DatabaseConnection> createDatabaseConnection() async {
  final result = await WasmDatabase.open(
    databaseName: 'flowplan',
    sqlite3Uri: Uri.parse('sqlite3.wasm'),
    driftWorkerUri: Uri.parse('drift_worker.dart.js'),
  );
  return result.resolvedExecutor;
}
